package com.gzhryc.shared_device.bxscn.core.protocol.v1.msg;

import com.gzhryc.common.IDTools;
import com.gzhryc.common.secruity.CRC16;

import java.io.Serializable;

public class CQRequest implements Serializable{

	private static final long serialVersionUID = 1L;
	
	private String cmd = "CQ";
	private String messageId;
	private Integer slotNum;

	public CQRequest() {
		this.messageId = IDTools.getTimestampSecondID();
	}

	public String getCmd() {
		return cmd;
	}
	
	public void setCmd(String cmd) {
		this.cmd = cmd;
	}
	
	public Integer getSlotNum() {
		return slotNum;
	}

	public void setSlotNum(Integer slotNum) {
		this.slotNum = slotNum;
	}

	public String getMessageId() {
		return messageId;
	}

	public void setMessageId(String messageId) {
		this.messageId = messageId;
	}
	
	public String getData() {
		String data = cmd+","+messageId+","+slotNum;
		return data;
	}

	public String getMessage() {
		String data = getData();
		String crc16 = CRC16.get((data+","+ BaseMessage.MESSAGE_KEY).getBytes());
		return "{"+data+","+crc16+"}";
	}

}
